﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CodeTemplate2.Models.Employee;

namespace CodeTemplate2.Mapper.Employee
{
    public class EmployeeMapper
    {
        public static EmployeeModel DtoToModel(EmployeeService.EmployeeDto inputDto)
        {
            EmployeeModel result = new EmployeeModel
            {
                Id = inputDto.Id,
                EmpId = inputDto.EmpId,
                Name = inputDto.Name,
                Surname = inputDto.Surname,
                Title = inputDto.Title,
                Address = inputDto.Address,
                JobTitle = inputDto.JobTitle.Id,
                MarriedStatus = inputDto.MarriedStatus,
                BirthDate = inputDto.BirthDate,
                Status = inputDto.Status,
                Branch = inputDto.Branch.Id,
            };

            return result;
        }

        public static EmployeeService.EmployeeDto ModelToDto(EmployeeModel inputModel)
        {
            EmployeeService.EmployeeDto result = new EmployeeService.EmployeeDto
            {
                Address = inputModel.Address,
                EmpId = inputModel.EmpId,
                JobTitle = new EmployeeService.PositionDto() { Id = inputModel.JobTitle },
                MarriedStatus = inputModel.MarriedStatus,
                Name = inputModel.Name,
                Status = inputModel.Status,
                Surname = inputModel.Surname,
                Title = inputModel.Title,
                BirthDate = inputModel.BirthDate,
                Id = inputModel.Id,
                Branch = new EmployeeService.BranchDto() { Id = inputModel.Branch },
            };

            return result;
        }

        public static List<EmployeeStatusModel> GetEmployeeStatusForDDL()
        {

            List<EmployeeStatusModel> result = GetEmployeeStatus();
            result.Add(new EmployeeStatusModel() { StatusId = 0, StatusName = "All" });

            return result.OrderBy(s => s.StatusId).ToList();
        }

        public static List<EmployeeStatusModel> GetEmployeeStatus()
        {
            //TODO get status list from BL
            List<EmployeeStatusModel> result = new List<EmployeeStatusModel>(){
                new EmployeeStatusModel(){ StatusId=1, StatusName="Active"},
                new EmployeeStatusModel(){ StatusId=2, StatusName="Inactive"}
            };
            return result;
        }
    }
}